package com.zhl.media.app.mvp.adapter;

import android.content.Context;

import com.jess.arms.di.component.AppComponent;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.utils.ArmsUtils;
import com.zhl.media.app.R;
import com.zhl.media.app.model.MediaPosition;
import com.zhl.media.commonsdk.enumeration.MediaCode;
import com.zhy.adapter.abslistview.CommonAdapter;
import com.zhy.adapter.abslistview.ViewHolder;

import java.util.List;

public class MediaGridViewAdapter extends CommonAdapter<MediaPosition> {

    private AppComponent mAppComponent;
    private ImageLoader mImageLoader;//用于加载图片的管理类,默认使用 Glide,使用策略模式,可替换框架
    public MediaGridViewAdapter(Context context, int layoutId, List<MediaPosition> datas) {
        super(context, layoutId, datas);
        mAppComponent = ArmsUtils.obtainAppComponentFromContext(context);
        mImageLoader = mAppComponent.imageLoader();
    }

    @Override
    protected void convert(ViewHolder viewHolder, MediaPosition item, int position) {

        //1空闲 2持续投放 3新换画

        if(item.getType()==1){
            viewHolder.setBackgroundRes(R.id.media_tv,R.drawable.shape_dddddd_5);
            viewHolder.setText(R.id.sheme_name,"");
            viewHolder.setText(R.id.media_tv,"");
            viewHolder.setText(R.id.media_code,item.getCode());
            viewHolder.setText(R.id.media_name,item.getMediaName());
        }else if(item.getType()==2){
            viewHolder.setBackgroundRes(R.id.media_tv,R.drawable.shape_dddddd_5);
            viewHolder.setText(R.id.sheme_name,item.getSchemeName());
            viewHolder.setText(R.id.media_code,item.getCode());
            viewHolder.setText(R.id.media_tv,item.getAlphabetIdentification());
            viewHolder.setText(R.id.media_name,item.getMediaName());
        }else if(item.getType()==3){
            viewHolder.setBackgroundRes(R.id.media_tv,R.drawable.shape_ff6600_5);
            viewHolder.setText(R.id.sheme_name,item.getSchemeName());
            viewHolder.setText(R.id.media_tv,item.getAlphabetIdentification());
            viewHolder.setText(R.id.media_code,item.getCode());
            viewHolder.setText(R.id.media_name,item.getMediaName());
        }
        //1待调整  2需补画  3完成调整 4已调整 5已完成 6初始值 7已拍照
        if (item.getStatus() == MediaCode.YWC){
            viewHolder.setText(R.id.paizhaookTv,MediaCode.YWC.getValue());
            viewHolder.setBackgroundRes(R.id.paizhaookTv,R.drawable.paizhao_ok_bg);
        }else if(item.getStatus() == MediaCode.DTZ){
            viewHolder.setText(R.id.paizhaookTv,MediaCode.DTZ.getValue());
            viewHolder.setBackgroundRes(R.id.paizhaookTv,R.drawable.dtz_bg);
        }else if(item.getStatus() == MediaCode.XBH){
            viewHolder.setText(R.id.paizhaookTv,MediaCode.XBH.getValue());
            viewHolder.setBackgroundRes(R.id.paizhaookTv,R.drawable.dtz_bg);
        }else if(item.getStatus() == MediaCode.WCTZ){
            viewHolder.setText(R.id.paizhaookTv,MediaCode.WCTZ.getValue());
            viewHolder.setBackgroundRes(R.id.paizhaookTv,R.drawable.paizhao_ok_bg);
        }else if(item.getStatus() == MediaCode.YTZ){
            viewHolder.setText(R.id.paizhaookTv,MediaCode.YTZ.getValue());
            viewHolder.setBackgroundRes(R.id.paizhaookTv,R.drawable.ytz_bg);
        }else if(item.getStatus() == MediaCode.CSZ){
            viewHolder.setText(R.id.paizhaookTv,MediaCode.CSZ.getValue());
            viewHolder.setBackgroundRes(R.id.paizhaookTv,0);
        } else if(item.getStatus() == MediaCode.YPZ){
            viewHolder.setText(R.id.paizhaookTv,MediaCode.YPZ.getValue());
            viewHolder.setBackgroundRes(R.id.paizhaookTv,R.drawable.paizhao_ok_bg);
        }
    }
}
